<?php

namespace MyBlog\Models;

use Illuminate\Database\Eloquent\Model;
use MyBlog\Libs\QiniuUtils;

class GalleryImg extends Model
{
    protected $guarded = array('id');
    
    public function gallery() {
    	return $this->belongsTo('MyBlog\Models\Gallery');
    }
    
    public function commonts() {
    	return $this->hasMany('MyBlog\Models\Comment');
    }
    
    public function imgUrl($dimension = null) {
    	$imgUrl = QiniuUtils::getUrl($this->img_path, $dimension);
    	return $imgUrl;
    }
    
    public static $rules = [
        'name' => 'required',
        'img_path' => 'required',
    ];

    public static $msgs = [
        'name.required' => '图片名称不能为空。',
        'img_path.required' => '图片地址不能为空。',
    ];
}
